{{ $hasCaption := isset .Params "caption" }}
{{ $caption    := .Get "caption" }}
{{ $captionEl  := printf "<table><caption style=\"display: none;\">%s</caption>" $caption }}
{{ $table      := .Inner | markdownify }}
{{ $html       := cond $hasCaption ($table | replaceRE "<table>" $captionEl) $table | safeHTML }}
{{ $html }}